﻿using AutoMapper;
using MediatR;
using SU.Center.Domain.SY;
using SU.Center.Infa;

namespace SU.Center.Api.Handler.TraceabilityMethod
{
    public class GetnowInformationHandler : IRequestHandler<GetnowInformationResultDto, ApiResult>
    {
        private readonly IBaseReposiotry<Information> baseReposiotry;
        private readonly IMapper mapper;
        private readonly ILogger<GetInformationHandler> logger;

        public GetnowInformationHandler(IBaseReposiotry<Information> baseReposiotry, IMapper mapper, ILogger<GetInformationHandler> logger)
        {
            this.baseReposiotry = baseReposiotry;
            this.mapper = mapper;
            this.logger = logger;
        }

        public async Task<ApiResult> Handle(GetnowInformationResultDto request, CancellationToken cancellationToken)
        {
            var list = await baseReposiotry.GetAsync(x => x.InformationId == request.InformationId);

            return ApiResult.Ok(list);
        }
    }
}

public class GetnowInformationResultDto : IRequest<ApiResult>
{
    public int InformationId { get; set; }
}
